home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / unix / volume25 / trash / part03 < prev    next >
Encoding:
Text File  |  1992-03-23  |  48.0 KB  |  2,446 lines

  1. Newsgroups: comp.sources.unix
  2. From: bruce@beta.cs.su.oz.au (Bruce Janson)
  3. Subject: v25i157: trash - simulate process execution in MIPS RISC/os 4.52, Part03/08
  4. Sender: unix-sources-moderator@pa.dec.com
  5. Approved: vixie@pa.dec.com
  6.  
  7. Submitted-By: bruce@beta.cs.su.oz.au (Bruce Janson)
  8. Posting-Number: Volume 25, Issue 157
  9. Archive-Name: trash/part03
  10.  
  11. #! /bin/sh
  12. # This is a shell archive.  Remove anything before this line, then unpack
  13. # it by saving it into a file and typing "sh file".  To overwrite existing
  14. # files, type "sh file -c".  You can also feed this as standard input via
  15. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  16. # will see the following message at the end:
  17. #        "End of archive 3 (of 8)."
  18. # Contents:  DIFFS i_c.c i_s.c main.c
  19. # Wrapped by bruce@basser on Tue Mar  3 23:25:22 1992
  20. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  21. if test -f 'DIFFS' -a "${1}" != "-c" ; then 
  22.   echo shar: Will not clobber existing file \"'DIFFS'\"
  23. else
  24. echo shar: Extracting \"'DIFFS'\" \(14311 characters\)
  25. sed "s/^X//" >'DIFFS' <<'END_OF_FILE'
  26. XMon Jun 24 ??:??:?? EST 1991
  27. Xsysv.c:        sys_recvfrom(): was copying out junk into *fromlenp
  28. X
  29. XTue Jun 25 07:21:56 EST 1991
  30. Xbsd43.c:    *(): replaced some quiet_proc* with mget/mput
  31. X
  32. XWed Jun 26 16:21:11 EST 1991
  33. Xbsd43.c:    *(): replaced some quiet_proc* with mget/mput
  34. X
  35. XSat Jun 29 01:52:57 EST 1991
  36. Xgo.c:        go(): print out pc with "unrecognised instrn" message
  37. X
  38. XSat Jun 29 01:53:45 EST 1991
  39. Xoptab.c:    added some i_c*() instructions
  40. Xi_c.c:            "
  41. X
  42. XSat Jun 29 23:49:21 EST 1991
  43. Xi_syscall.c:    result spec. for syscalls that return 2 results
  44. Xbsd43.c:        "
  45. Xsysv.c:            "
  46. Xmakefile:    incorporated *.u support
  47. X
  48. XTue Jul  2 13:06:27 EST 1991
  49. Xmakefile:    tidied up .u/utrash strand
  50. Xtrash.1:    added H desc.
  51. X
  52. XTue Jul  2 13:07:17 EST 1991
  53. Xmakefile:    replaced cc with /bin/cc
  54. X
  55. XTue Jul  2 23:41:31 EST 1991
  56. Xi_syscall.c:    'u' = unsigned long type
  57. Xbsd43.c:        "
  58. Xsysv.c:            "
  59. X
  60. XWed Jul  3 23:07:19 EST 1991
  61. Xi_syscall.c:    replaced explicit syscall table lookup with function call
  62. Xbsd43.c:    defined function for above and removed global variables
  63. Xsysv.c:            "
  64. Xposix.c:        "
  65. X
  66. XThu Jul  4 00:50:19 EST 1991
  67. Xsysv.c:        added some basser-specific syscall support (LIMITS, SHARE)
  68. Xmuck:        created: basser use only -- the right #defines don't exist
  69. X
  70. XFri Jul  5 22:32:37 EST 1991
  71. Xi_syscall.c:    (suggestion: greg@cxsyd.cx.oz.au) rationalised I/O
  72. X        data escapes
  73. X
  74. XSat Jul  6 01:25:23 EST 1991
  75. Xi_syscall.c:    (suggestion: greg@cxsyd.cx.oz.au) changed time
  76. X        representation
  77. Xbsd43.c:        "
  78. Xsysv.c:            "
  79. X
  80. XTue Jul 16 03:47:35 EST 1991
  81. X<various>:    added vcouldnot()
  82. X
  83. XSat Jul 20 02:14:18 EST 1991
  84. Xi_d.c:        added "divide by 0" checks
  85. X
  86. XWed Aug  7 17:21:35 EST 1991
  87. Xsysv.c:        made sysv signal() work for SIG_IGN and SIG_DFL
  88. X
  89. XWed Aug  7 17:22:31 EST 1991
  90. Xsysv.c:        added support for fcntl(.., F_SETLK, ..)
  91. X
  92. XThu Aug  8 11:50:29 EST 1991
  93. Xmain.c:        added version_string and "-v"
  94. X
  95. XFri Aug  9 02:36:45 EST 1991
  96. Xmain.c:        fixed bug in canonical argument format ("-sh" was
  97. X        being interpreted as further arguments by getopt()
  98. X        rather than as argv[0])
  99. X
  100. XFri Aug  9 02:38:42 EST 1991
  101. Xmain.c:        added support for "#!" executable interpreter scripts
  102. Xsysv.c:            "
  103. Xbsd43.c:        "
  104. Xprocess.c:        "
  105. Xload.c:            "
  106. X
  107. XSat Aug 17 13:26:21 EST 1991
  108. Xprocess.h:    typo in Procmgettextword(): changed "unsigned char"
  109. X            to "unsigned char *"
  110. X
  111. XSun Aug 18 03:42:07 EST 1991
  112. Xmakefile:    added dependencies for .u support
  113. X
  114. XSun Aug 18 03:42:38 EST 1991
  115. Xprocess.h:    improved calculation of taddr in Procmgettextword()
  116. X
  117. XMon Aug 19 22:38:26 EST 1991
  118. Xflag.h:        isolated common flag print code
  119. Xbsd43.c:        "
  120. Xsysv.c:            "
  121. X
  122. XMon Aug 19 22:38:36 EST 1991
  123. Xbsd43.c:    made bsd43 sigvec() work for SIG_IGN and SIG_DFL, plus
  124. X            other minor sig fixes
  125. X
  126. XFri Aug 30 21:05:27 EST 1991
  127. Xmain.c:        sent out first of Version 1
  128. X
  129. XWed Sep  4 19:35:11 EST 1991
  130. Xsysv.c:        added (incomplete) defn of sigreturn()
  131. X
  132. XThu Sep  5 16:51:10 EST 1991
  133. Xsysv.c:        added (undocumented) SETOWN to sys_fcntl()
  134. X
  135. XMon Sep  9 01:59:48 EST 1991
  136. Xsysv.c:        completed (sysv) signal support
  137. X
  138. XMon Sep  9 02:00:43 EST 1991
  139. Xsysv.c:        enabled alarm() syscall
  140. X
  141. XMon Sep  9 19:58:42 EST 1991
  142. Xsysv.c:        removed "bsd.h"
  143. Xmakefile:    removed "bsd.h"
  144. X
  145. XMon Sep  9 20:58:22 EST 1991
  146. Xi_syscall.c:    formats for wait3 args
  147. Xsysv.c:        formats for wait3 args
  148. X
  149. XTue Sep 10 00:02:08 EST 1991
  150. Xi_syscall.c:    format for times args
  151. X
  152. XTue Sep 10 19:54:11 EST 1991
  153. Xsysv.c:        fixed bug in sigreturn -- don't overwrite registers on return
  154. X
  155. XSat Sep 14 01:29:27 EST 1991
  156. Xmyldopen.c:    (bug: greg@cxsyd.cx.oz.au) fixed EBADF bug in myldopen()
  157. X
  158. XTue Sep 24 20:28:44 EST 1991
  159. Xsysv.c:        delayed sigrelse() call until just before next instrn
  160. Xgo.c:        delayed sigrelse() call until just before next instrn
  161. X
  162. XFri Oct 11 15:37:50 EST 1991
  163. Xprocess.c:    (bug: roy@cs.su.oz.au) vcouldnot() error messages during startup
  164. Xsyms.c:        (bug: roy@cs.su.oz.au) vcouldnot() error messages during startup
  165. X
  166. XMon Oct 14 20:02:46 EST 1991
  167. Xsysv.c:        sysv_utssys() ustat() support
  168. X
  169. XSat Oct 26 21:04:42 EST 1991
  170. Xbsd43.c:    (bug: kmk@cc.tut.fi) sys_statfs() was using wrong args
  171. X
  172. XSat Oct 26 21:26:24 EST 1991
  173. Xmain.c:        sent out first of Version 2
  174. X
  175. XWed Oct 30 02:49:04 EST 1991
  176. Xbsd43.c:    added support for bsd43_sysmips(.., HWCONF, ..)
  177. Xbsd43.c:    tidied up code for bsd43_sysmips(.., GETRUSAGE, ..)
  178. X
  179. XWed Oct 30 03:11:00 EST 1991
  180. Xbsd43.c:    added support for bsd43_ioctl(.., FLIOC_SENSE_DRIVE, ..)
  181. X
  182. XSat Nov  9 05:05:17 EST 1991
  183. Xload.c:        replaced procmput() with a quiet_procmput() -- odd...
  184. X
  185. XWed Nov 13 17:07:11 EST 1991
  186. Xmain.c:        added support for C flag
  187. Xprocess.h:    added support for C flag
  188. Xprocess.c:    added support for C flag
  189. Xtrash.1:    added support for C flag
  190. X
  191. XWed Nov 13 17:59:46 EST 1991
  192. Xsysv.c:        rearrangements for interconnected sys_ioctl
  193. Xbsd43.c:    rearrangements for interconnected sys_ioctl
  194. Xsgttyb.c:    rearrangements for interconnected sys_ioctl
  195. X
  196. XThu Nov 14 16:50:00 EST 1991
  197. Xsysv.c:        added support for sysv_ioctl(.., oFIO[N]CLEX, ..)
  198. X
  199. XSat Nov 16 01:28:44 EST 1991
  200. Xi_syscall.c:    ensure -P behaviour after encountering unimplemented
  201. X        syscall feature
  202. X
  203. XSat Nov 16 19:15:14 EST 1991
  204. Xsysv.c:        added support for MTIOCGET
  205. X
  206. XSat Nov 16 21:08:09 EST 1991
  207. Xsysv.c:        added support for MTIOCTOP
  208. X
  209. XSat Nov 16 21:08:09 EST 1991
  210. Xbsd43.c:    added support for bsd43_sysmips(BSD43_MIPS_WAIT3, ..)
  211. X
  212. XSun Dec  8 14:17:14 EST 1991
  213. Xi_syscall.c:    print correct field of sockaddr_in in say_addr()
  214. X
  215. XSun Dec  8 16:11:13 EST 1991
  216. Xmain.c:        extend Aflag to show execve() env vector
  217. Xi_syscall.c:    extend Aflag to show execve() env vector
  218. Xsysv.c:        extend Aflag to show execve() env vector
  219. Xbsd43.c:    extend Aflag to show execve() env vector
  220. Xtrash.1:    extend Aflag to show execve() env vector
  221. X
  222. XSun Dec  8 16:16:58 EST 1991
  223. Xmakefile:    increased -Olimit from 571 to 600
  224. X
  225. XTue Dec 31 15:38:12 EST 1991
  226. Xprocess.h:    added support for NMAGIC (both types) and OMAGIC files
  227. Xprocess.c:    added support for NMAGIC (both types) and OMAGIC files
  228. X
  229. XTue Dec 31 17:36:48 EST 1991
  230. Xmakefile:    added comment about use of CHMOD
  231. X
  232. XThu Jan  2 10:20:53 EST 1992
  233. Xsysv.c:        fixed inherited fd bug
  234. Xbsd43.c:    fixed inherited fd bug
  235. Xmain.c:        fixed inherited fd bug
  236. Xprocess.c:    fixed inherited fd bug
  237. Xsyms.c:        fixed inherited fd bug
  238. Xmakefile:    fixed inherited fd bug
  239. Xload.c:        fixed inherited fd bug
  240. Xfd.c:        fixed inherited fd bug
  241. Xtrash.1:    fixed inherited fd bug
  242. X
  243. XMon Jan  6 11:50:54 EST 1992
  244. Xprocess.c:    fflush log file in procclose()
  245. X
  246. XMon Jan  6 11:53:37 EST 1992
  247. Xfd.c:        fd_invalid() now sets EBADF
  248. X
  249. XMon Jan  6 11:54:43 EST 1992
  250. Xmakefile:    added entries for generic.[chou]
  251. Xgeneric.c:    created
  252. Xgeneric.h:    created
  253. Xsysv.c:        replaced syscalls with generics
  254. Xbsd43.c:    replaced syscalls with generics
  255. Xi_syscall.c:    now explicitly passes syscallno to syscall
  256. X
  257. XMon Jan  6 12:04:21 EST 1992
  258. Xsysv.c:        added support for /proc fcntl()'s
  259. X
  260. XMon Jan  6 23:52:57 EST 1992
  261. Xsysv.c:        added support for ioctl(TCSETA[FW]) arg printing
  262. X
  263. XTue Jan  7 18:59:49 EST 1992
  264. Xsysv.c:        added support for fcntl(PFCSTOP)
  265. X
  266. XTue Jan  7 19:05:08 EST 1992
  267. Xi_syscall.c:    added support for /proc fcntl() cmd printing
  268. X
  269. XTue Jan  7 20:01:50 EST 1992
  270. Xi_syscall.c:    rationalised post-syscall return_errno code slightly
  271. X
  272. XTue Jan  7 21:12:53 EST 1992
  273. Xprocess.c:    proc_mget() and proc_mput() now do nothing when length == 0
  274. X
  275. XTue Jan  7 21:46:33 EST 1992
  276. Xsysv.c:        added support for fcntl(PFCGETPR)
  277. Xi_syscall.c:    added support for fcntl(PFCGETPR)
  278. X
  279. XThu Jan  9 23:49:55 EST 1992
  280. Xsysv.c:        made sys_ofcntl() more like sys_fcntl()
  281. X
  282. XFri Jan 10 00:47:03 EST 1992
  283. Xsysv.c:        sysv_SIGNAL() now prints truncated form unless Aflag
  284. X
  285. XMon Jan 13 18:47:12 EST 1992
  286. Xsysv.c:        setpgrp() has 1 argument, not 0
  287. X
  288. XMon Jan 13 23:55:26 EST 1992
  289. Xgeneric.c:    added PIXIE test in exit
  290. X
  291. XSat Jan 18 14:33:31 EST 1992
  292. Xi_syscall.c:    extend Aflag to show execve() arg vector
  293. Xtrash.1:    extend Aflag to show execve() arg vector
  294. X
  295. XThu Jan 23 00:48:57 EST 1992
  296. Xcouldnot.c:    flush outfp before _exit()
  297. Xvcouldnot.c:    flush outfp before _exit()
  298. X
  299. XThu Jan 23 01:38:41 EST 1992
  300. Xmakefile:    -O3 rather than -O4: seemed to run faster...
  301. X
  302. XThu Jan 23 01:39:17 EST 1992
  303. Xgeneric.c:    if defined(PIXIE) then exit() else _exit()
  304. X
  305. XThu Jan 23 01:39:54 EST 1992
  306. Xentry.h:    created: hashed table of binary trees of decoded instrn pages
  307. Xdiblock.c:    created: hashed table of binary trees of decoded instrn pages
  308. Xdiblock.h:    created: hashed table of binary trees of decoded instrn pages
  309. Xtalloc.h:    created: hashed table of binary trees of decoded instrn pages
  310. X
  311. XThu Jan 23 01:40:04 EST 1992
  312. Xregister.h:    changed to threaded decoded instruction scheme
  313. Xvcouldnot.c:    changed to threaded decoded instruction scheme
  314. Xgeneric.c:    changed to threaded decoded instruction scheme
  315. Xhistory.c:    changed to threaded decoded instruction scheme
  316. Xload.c:        changed to threaded decoded instruction scheme
  317. Xoptab.c:    changed to threaded decoded instruction scheme
  318. Xi_o.c:        changed to threaded decoded instruction scheme
  319. Xi_x.c:        changed to threaded decoded instruction scheme
  320. Xi_n.c:        changed to threaded decoded instruction scheme
  321. Xinstruction.h:    changed to threaded decoded instruction scheme
  322. Xi_u.c:        changed to threaded decoded instruction scheme
  323. Xi_syscall.c:    changed to threaded decoded instruction scheme
  324. Xi_d.c:        changed to threaded decoded instruction scheme
  325. Xi_m.c:        changed to threaded decoded instruction scheme
  326. Xi_s.c:        changed to threaded decoded instruction scheme
  327. Xi_a.c:        changed to threaded decoded instruction scheme
  328. Xi_b.c:        changed to threaded decoded instruction scheme
  329. Xsysv.c:        changed to threaded decoded instruction scheme
  330. Xi_j.c:        changed to threaded decoded instruction scheme
  331. Xbsd43.c:    changed to threaded decoded instruction scheme
  332. Xi_l.c:        changed to threaded decoded instruction scheme
  333. Xprocess.h:    changed to threaded decoded instruction scheme
  334. Xgo.c:        changed to threaded decoded instruction scheme
  335. Xi_c.c:        changed to threaded decoded instruction scheme
  336. Xprocess.c:    changed to threaded decoded instruction scheme
  337. Xmakefile:    changed to threaded decoded instruction scheme
  338. X
  339. XThu Jan 23 10:15:42 EST 1992
  340. Xsysv.c:        added support for sysfs()
  341. X
  342. XFri Jan 24 21:03:24 EST 1992
  343. Xgeneric.c:    replaced most calls to mgetstring() with mgets()
  344. Xi_syscall.c:    replaced most calls to mgetstring() with mgets()
  345. Xbsd43.c:    replaced most calls to mgetstring() with mgets()
  346. Xsysv.c:        replaced most calls to mgetstring() with mgets()
  347. X
  348. XSun Jan 26 22:43:26 EST 1992
  349. Xmain.c:        Version 3
  350. X
  351. XTue Jan 28 00:22:52 EST 1992
  352. Xgetprbyno.c:    changed to getprbyno.c from getprotobynumber.c (>12 chars)
  353. Xmakefile:    changed to getprbyno.c from getprotobynumber.c (>12 chars)
  354. X
  355. XTue Jan 28 00:27:31 EST 1992
  356. Xinstrn.h:    changed to instrn.h from instruction.h (>12 chars)
  357. Xmakefile:    changed to instrn.h from instruction.h (>12 chars)
  358. X*.c:        changed to instrn.h from instruction.h (>12 chars)
  359. X
  360. XWed Jan 29 18:38:08 EST 1992
  361. Xprocess.c:    reject processes that call shared libraries
  362. X
  363. XWed Jan 29 18:38:57 EST 1992
  364. Xvcouldnot.c:    checked dipc before indirecting through it
  365. X
  366. XWed Feb  5 22:57:16 EST 1992
  367. XREADME:        added ack to Robert Bedichek
  368. X
  369. XFri Feb  7 20:56:59 EST 1992
  370. Xsysv.c:        (bug: roy@cs.su.oz.au) added support for poll()
  371. X
  372. XMon Feb 10 13:19:17 EST 1992
  373. Xinstrn.h:    dipc now an argument and handlers now return dinstrn *
  374. Xoptab.c:    dipc now an argument and handlers now return dinstrn *
  375. Xdiblock.h:    dipc now an argument and handlers now return dinstrn *
  376. Xdiblock.c:    dipc now an argument and handlers now return dinstrn *
  377. Xgo.c:        dipc now an argument and handlers now return dinstrn *
  378. Xbsd43.c:    dipc now an argument and handlers now return dinstrn *
  379. Xgeneric.c:    dipc now an argument and handlers now return dinstrn *
  380. Xhistory.c:    dipc now an argument and handlers now return dinstrn *
  381. Xload.c:        dipc now an argument and handlers now return dinstrn *
  382. Xprocess.c:    dipc now an argument and handlers now return dinstrn *
  383. Xsysv.c:        dipc now an argument and handlers now return dinstrn *
  384. Xvcouldnot.c:    dipc now an argument and handlers now return dinstrn *
  385. Xprocess.h:    dipc now an argument and handlers now return dinstrn *
  386. Xi_*.c:        dipc now an argument and handlers now return dinstrn *
  387. X
  388. XMon Feb 10 13:28:26 EST 1992
  389. Xmain.c:        vcouldnot() -> couldnot()
  390. X
  391. XMon Feb 10 22:45:50 EST 1992
  392. Xfd.c:        removed extern decls of *couldnot()
  393. Xprocess.c:    removed extern decls of *couldnot()
  394. X
  395. XMon Feb 10 22:45:55 EST 1992
  396. Xmain.c:        Version 4
  397. X
  398. XMon Feb 10 22:46:03 EST 1992
  399. Xi_j.c:        tidied up a little
  400. X
  401. XMon Feb 10 22:46:03 EST 1992
  402. Xprocess.h:    moved quiet_procmget_word() into i_l.c
  403. Xi_l.c:        moved quiet_procmget_word() into i_l.c
  404. Xprocess.h:    moved quiet_procmput_word() into i_s.c
  405. Xi_s.c:        moved quiet_procmput_word() into i_s.c
  406. X
  407. XMon Feb 10 22:46:03 EST 1992
  408. Xi_l.c:        added new handlers
  409. Xi_s.c:        added new handlers
  410. X
  411. XTue Feb 11 01:30:00 EST 1992
  412. Xi_a.c:        added explicit calls to "c_" routines from "i_" routines
  413. Xi_b.c:        added explicit calls to "c_" routines from "i_" routines
  414. Xi_d.c:        added explicit calls to "c_" routines from "i_" routines
  415. Xi_j.c:        added explicit calls to "c_" routines from "i_" routines
  416. Xi_l.c:        added explicit calls to "c_" routines from "i_" routines
  417. Xi_m.c:        added explicit calls to "c_" routines from "i_" routines
  418. Xi_s.c:        added explicit calls to "c_" routines from "i_" routines
  419. X
  420. XTue Feb 11 05:00:00 EST 1992
  421. Xi_l.c:        parameterised quiet_procm??t_word() to work with char, short and long
  422. X
  423. XFri Feb 14 00:45:42 EST 1992
  424. Xmakefile:    added PFLAG
  425. X
  426. XSat Feb 15 01:38:59 EST 1992
  427. Xprocess.h:    replaced calls to mget() with calls to "in-place" dmget()
  428. Xprocess.c:    replaced calls to mget() with calls to "in-place" dmget()
  429. Xbsd43.c:    replaced calls to mget() with calls to "in-place" dmget()
  430. Xgeneric.c:    replaced calls to mget() with calls to "in-place" dmget()
  431. Xi_syscall.c:    replaced calls to mget() with calls to "in-place" dmget()
  432. Xsysv.c:        replaced calls to mget() with calls to "in-place" dmget()
  433. X
  434. XSat Feb 15 19:06:41 EST 1992
  435. Xprocess.c:    added "wcache": load/store memory access cache
  436. Xwcache.c:    added "wcache": load/store memory access cache
  437. Xwcache.h:    added "wcache": load/store memory access cache
  438. Xmakefile:    added "wcache": load/store memory access cache
  439. Xi_l.c:        added "wcache": load/store memory access cache
  440. Xi_s.c:        added "wcache": load/store memory access cache
  441. X
  442. XMon Feb 17 20:40:18 EST 1992
  443. Xi_l.c:        tidied up quiet_procmget_word()
  444. Xi_s.c:        tidied up quiet_procmput_word()
  445. X
  446. XMon Feb 17 20:41:35 EST 1992
  447. Xprocess.h:    rearranged some statements -- seemed to generate faster code
  448. X
  449. XFri Feb 28 20:34:00 EST 1992
  450. Xsysv.c:        bug: sysv_print_sigcontext() now returns an int as declared
  451. X
  452. XFri Feb 28 22:05:10 EST 1992
  453. Xi_a.c:        speedup: added c_addi()
  454. Xi_s.c:        speedup: added c_slt()
  455. X
  456. XSat Feb 29 21:49:31 EST 1992
  457. Xgo.c:        changed "emergency" tracing code slightly in interpret()
  458. Xi_s.c:        bug: fixed in c_slt()
  459. X
  460. XTue Mar  3 23:00:52 EST 1992
  461. Xmain.c:        Version 5
  462. END_OF_FILE
  463. if test 14311 -ne `wc -c <'DIFFS'`; then
  464.     echo shar: \"'DIFFS'\" unpacked with wrong size!
  465. fi
  466. # end of 'DIFFS'
  467. fi
  468. if test -f 'i_c.c' -a "${1}" != "-c" ; then 
  469.   echo shar: Will not clobber existing file \"'i_c.c'\"
  470. else
  471. echo shar: Extracting \"'i_c.c'\" \(8817 characters\)
  472. sed "s/^X//" >'i_c.c' <<'END_OF_FILE'
  473. X#include    "register.h"
  474. X#include    "symtab.h"
  475. X#include    "diblock.h"
  476. X#include    "instrn.h"
  477. X#include    "process.h"
  478. X
  479. Xdinstrn    *
  480. Xi_ceq(dipc, fmt, ft, fs, fd)
  481. Xdinstrn    *dipc;
  482. Xint        fmt;
  483. Xint        ft;
  484. Xint        fs;
  485. Xint        fd;
  486. X{
  487. X    float        singles;
  488. X    float        singlet;
  489. X    double        doubles;
  490. X    double        doublet;
  491. X    int        result;
  492. X    unsigned long    cs;
  493. X
  494. X    /*
  495. X     * equal
  496. X     */
  497. X    switch (fmt)
  498. X    {
  499. X    case FMT_SINGLE:
  500. X        procsget(CP1G(fs), *(unsigned long *)&singles);
  501. X
  502. X        procsget(CP1G(ft), *(unsigned long *)&singlet);
  503. X
  504. X        result = (singles == singlet);
  505. X
  506. X        break;
  507. X
  508. X    case FMT_DOUBLE:
  509. X        /*
  510. X         * Note apparent reversal of words within
  511. X         * doubles here -- no idea why.
  512. X         */
  513. X        procsget(CP1G(fs), *((unsigned long *)&doubles + 1));
  514. X
  515. X        procsget(CP1G(fs) + 1, *(unsigned long *)&doubles);
  516. X
  517. X        procsget(CP1G(ft), *((unsigned long *)&doublet + 1));
  518. X
  519. X        procsget(CP1G(ft) + 1, *(unsigned long *)&doublet);
  520. X
  521. X        result = (doubles == doublet);
  522. X
  523. X        break;
  524. X
  525. X    default:
  526. X        unrecognised(dipc);
  527. X        break;
  528. X    }
  529. X
  530. X    procsget(CP1CS, cs);
  531. X
  532. X    Set_Cond(cs, result);
  533. X
  534. X    procsput(CP1CS, cs);
  535. X
  536. X    return dipc;
  537. X}
  538. X
  539. Xdinstrn    *
  540. Xi_cfc1(dipc, rt, fs)
  541. Xdinstrn    *dipc;
  542. Xint        rt;
  543. Xint        fs;
  544. X{
  545. X    unsigned long    s;
  546. X
  547. X    procsget(CP1C(fs), s);
  548. X
  549. X    procsput(rt, s);
  550. X
  551. X    return dipc;
  552. X}
  553. X
  554. Xdinstrn    *
  555. Xi_cle(dipc, fmt, ft, fs, fd)
  556. Xdinstrn    *dipc;
  557. Xint        fmt;
  558. Xint        ft;
  559. Xint        fs;
  560. Xint        fd;
  561. X{
  562. X    float        singles;
  563. X    float        singlet;
  564. X    double        doubles;
  565. X    double        doublet;
  566. X    int        result;
  567. X    unsigned long    cs;
  568. X
  569. X    /*
  570. X     * less than || equal
  571. X     *
  572. X     * TODO: exception if unordered
  573. X     */
  574. X    switch (fmt)
  575. X    {
  576. X    case FMT_SINGLE:
  577. X        procsget(CP1G(fs), *(unsigned long *)&singles);
  578. X
  579. X        procsget(CP1G(ft), *(unsigned long *)&singlet);
  580. X
  581. X        result = (singles <= singlet);
  582. X
  583. X        break;
  584. X
  585. X    case FMT_DOUBLE:
  586. X        /*
  587. X         * Note apparent reversal of words within
  588. X         * doubles here -- no idea why.
  589. X         */
  590. X        procsget(CP1G(fs), *((unsigned long *)&doubles + 1));
  591. X
  592. X        procsget(CP1G(fs) + 1, *(unsigned long *)&doubles);
  593. X
  594. X        procsget(CP1G(ft), *((unsigned long *)&doublet + 1));
  595. X
  596. X        procsget(CP1G(ft) + 1, *(unsigned long *)&doublet);
  597. X
  598. X        result = (doubles <= doublet);
  599. X
  600. X        break;
  601. X
  602. X    default:
  603. X        unrecognised(dipc);
  604. X        break;
  605. X    }
  606. X
  607. X    procsget(CP1CS, cs);
  608. X
  609. X    Set_Cond(cs, result);
  610. X
  611. X    procsput(CP1CS, cs);
  612. X
  613. X    return dipc;
  614. X}
  615. X
  616. Xdinstrn    *
  617. Xi_clt(dipc, fmt, ft, fs, fd)
  618. Xdinstrn    *dipc;
  619. Xint        fmt;
  620. Xint        ft;
  621. Xint        fs;
  622. Xint        fd;
  623. X{
  624. X    float        singles;
  625. X    float        singlet;
  626. X    double        doubles;
  627. X    double        doublet;
  628. X    int        result;
  629. X    unsigned long    cs;
  630. X
  631. X    /*
  632. X     * less than
  633. X     *
  634. X     * TODO: exception if unordered
  635. X     */
  636. X    switch (fmt)
  637. X    {
  638. X    case FMT_SINGLE:
  639. X        procsget(CP1G(fs), *(unsigned long *)&singles);
  640. X
  641. X        procsget(CP1G(ft), *(unsigned long *)&singlet);
  642. X
  643. X        result = (singles < singlet);
  644. X
  645. X        break;
  646. X
  647. X    case FMT_DOUBLE:
  648. X        /*
  649. X         * Note apparent reversal of words within
  650. X         * doubles here -- no idea why.
  651. X         */
  652. X        procsget(CP1G(fs), *((unsigned long *)&doubles + 1));
  653. X
  654. X        procsget(CP1G(fs) + 1, *(unsigned long *)&doubles);
  655. X
  656. X        procsget(CP1G(ft), *((unsigned long *)&doublet + 1));
  657. X
  658. X        procsget(CP1G(ft) + 1, *(unsigned long *)&doublet);
  659. X
  660. X        result = (doubles < doublet);
  661. X
  662. X        break;
  663. X
  664. X    default:
  665. X        unrecognised(dipc);
  666. X        break;
  667. X    }
  668. X
  669. X    procsget(CP1CS, cs);
  670. X
  671. X    Set_Cond(cs, result);
  672. X
  673. X    procsput(CP1CS, cs);
  674. X
  675. X    return dipc;
  676. X}
  677. X
  678. Xdinstrn    *
  679. Xi_cole(dipc, fmt, ft, fs, fd)
  680. Xdinstrn    *dipc;
  681. Xint        fmt;
  682. Xint        ft;
  683. Xint        fs;
  684. Xint        fd;
  685. X{
  686. X    float        singles;
  687. X    float        singlet;
  688. X    double        doubles;
  689. X    double        doublet;
  690. X    int        result;
  691. X    unsigned long    cs;
  692. X
  693. X    /*
  694. X     * ordered && (less than || equal)
  695. X     * (see p.7-6)
  696. X     *
  697. X     * TODO: ordered
  698. X     */
  699. X    switch (fmt)
  700. X    {
  701. X    case FMT_SINGLE:
  702. X        procsget(CP1G(fs), *(unsigned long *)&singles);
  703. X
  704. X        procsget(CP1G(ft), *(unsigned long *)&singlet);
  705. X
  706. X        result = (singles <= singlet);
  707. X
  708. X        break;
  709. X
  710. X    case FMT_DOUBLE:
  711. X        /*
  712. X         * Note apparent reversal of words within
  713. X         * doubles here -- no idea why.
  714. X         */
  715. X        procsget(CP1G(fs), *((unsigned long *)&doubles + 1));
  716. X
  717. X        procsget(CP1G(fs) + 1, *(unsigned long *)&doubles);
  718. X
  719. X        procsget(CP1G(ft), *((unsigned long *)&doublet + 1));
  720. X
  721. X        procsget(CP1G(ft) + 1, *(unsigned long *)&doublet);
  722. X
  723. X        result = (doubles <= doublet);
  724. X
  725. X        break;
  726. X
  727. X    default:
  728. X        unrecognised(dipc);
  729. X        break;
  730. X    }
  731. X
  732. X    procsget(CP1CS, cs);
  733. X
  734. X    Set_Cond(cs, result);
  735. X
  736. X    procsput(CP1CS, cs);
  737. X
  738. X    return dipc;
  739. X}
  740. X
  741. Xdinstrn    *
  742. Xi_colt(dipc, fmt, ft, fs, fd)
  743. Xdinstrn    *dipc;
  744. Xint        fmt;
  745. Xint        ft;
  746. Xint        fs;
  747. Xint        fd;
  748. X{
  749. X    float        singles;
  750. X    float        singlet;
  751. X    double        doubles;
  752. X    double        doublet;
  753. X    int        result;
  754. X    unsigned long    cs;
  755. X
  756. X    /*
  757. X     * ordered && less than
  758. X     * (see p.7-6)
  759. X     *
  760. X     * TODO: ordered
  761. X     */
  762. X    switch (fmt)
  763. X    {
  764. X    case FMT_SINGLE:
  765. X        procsget(CP1G(fs), *(unsigned long *)&singles);
  766. X
  767. X        procsget(CP1G(ft), *(unsigned long *)&singlet);
  768. X
  769. X        result = (singles < singlet);
  770. X
  771. X        break;
  772. X
  773. X    case FMT_DOUBLE:
  774. X        /*
  775. X         * Note apparent reversal of words within
  776. X         * doubles here -- no idea why.
  777. X         */
  778. X        procsget(CP1G(fs), *((unsigned long *)&doubles + 1));
  779. X
  780. X        procsget(CP1G(fs) + 1, *(unsigned long *)&doubles);
  781. X
  782. X        procsget(CP1G(ft), *((unsigned long *)&doublet + 1));
  783. X
  784. X        procsget(CP1G(ft) + 1, *(unsigned long *)&doublet);
  785. X
  786. X        result = (doubles < doublet);
  787. X
  788. X        break;
  789. X
  790. X    default:
  791. X        unrecognised(dipc);
  792. X        break;
  793. X    }
  794. X
  795. X    procsget(CP1CS, cs);
  796. X
  797. X    Set_Cond(cs, result);
  798. X
  799. X    procsput(CP1CS, cs);
  800. X
  801. X    return dipc;
  802. X}
  803. X
  804. Xdinstrn    *
  805. Xi_ctc1(dipc, rt, fs)
  806. Xdinstrn    *dipc;
  807. Xint        rt;
  808. Xint        fs;
  809. X{
  810. X    unsigned long    t;
  811. X
  812. X    procsget(rt, t);
  813. X
  814. X    procsput(CP1C(fs), t);
  815. X
  816. X    return dipc;
  817. X}
  818. X
  819. Xdinstrn    *
  820. Xi_cule(dipc, fmt, ft, fs, fd)
  821. Xdinstrn    *dipc;
  822. Xint        fmt;
  823. Xint        ft;
  824. Xint        fs;
  825. Xint        fd;
  826. X{
  827. X    float        singles;
  828. X    float        singlet;
  829. X    double        doubles;
  830. X    double        doublet;
  831. X    int        result;
  832. X    unsigned long    cs;
  833. X
  834. X    /*
  835. X     * less than || equal
  836. X     *
  837. X     * TODO: unordered
  838. X     */
  839. X    switch (fmt)
  840. X    {
  841. X    case FMT_SINGLE:
  842. X        procsget(CP1G(fs), *(unsigned long *)&singles);
  843. X
  844. X        procsget(CP1G(ft), *(unsigned long *)&singlet);
  845. X
  846. X        result = (singles <= singlet);
  847. X
  848. X        break;
  849. X
  850. X    case FMT_DOUBLE:
  851. X        /*
  852. X         * Note apparent reversal of words within
  853. X         * doubles here -- no idea why.
  854. X         */
  855. X        procsget(CP1G(fs), *((unsigned long *)&doubles + 1));
  856. X
  857. X        procsget(CP1G(fs) + 1, *(unsigned long *)&doubles);
  858. X
  859. X        procsget(CP1G(ft), *((unsigned long *)&doublet + 1));
  860. X
  861. X        procsget(CP1G(ft) + 1, *(unsigned long *)&doublet);
  862. X
  863. X        result = (doubles <= doublet);
  864. X
  865. X        break;
  866. X
  867. X    default:
  868. X        unrecognised(dipc);
  869. X        break;
  870. X    }
  871. X
  872. X    procsget(CP1CS, cs);
  873. X
  874. X    Set_Cond(cs, result);
  875. X
  876. X    procsput(CP1CS, cs);
  877. X
  878. X    return dipc;
  879. X}
  880. X
  881. Xdinstrn    *
  882. Xi_cult(dipc, fmt, ft, fs, fd)
  883. Xdinstrn    *dipc;
  884. Xint        fmt;
  885. Xint        ft;
  886. Xint        fs;
  887. Xint        fd;
  888. X{
  889. X    float        singles;
  890. X    float        singlet;
  891. X    double        doubles;
  892. X    double        doublet;
  893. X    int        result;
  894. X    unsigned long    cs;
  895. X
  896. X    /*
  897. X     * unordered || less than
  898. X     * (see p.7-6)
  899. X     *
  900. X     * TODO: unordered
  901. X     */
  902. X    switch (fmt)
  903. X    {
  904. X    case FMT_SINGLE:
  905. X        procsget(CP1G(fs), *(unsigned long *)&singles);
  906. X
  907. X        procsget(CP1G(ft), *(unsigned long *)&singlet);
  908. X
  909. X        result = (singles < singlet);
  910. X
  911. X        break;
  912. X
  913. X    case FMT_DOUBLE:
  914. X        /*
  915. X         * Note apparent reversal of words within
  916. X         * doubles here -- no idea why.
  917. X         */
  918. X        procsget(CP1G(fs), *((unsigned long *)&doubles + 1));
  919. X
  920. X        procsget(CP1G(fs) + 1, *(unsigned long *)&doubles);
  921. X
  922. X        procsget(CP1G(ft), *((unsigned long *)&doublet + 1));
  923. X
  924. X        procsget(CP1G(ft) + 1, *(unsigned long *)&doublet);
  925. X
  926. X        result = (doubles < doublet);
  927. X
  928. X        break;
  929. X
  930. X    default:
  931. X        unrecognised(dipc);
  932. X        break;
  933. X    }
  934. X
  935. X    procsget(CP1CS, cs);
  936. X
  937. X    Set_Cond(cs, result);
  938. X
  939. X    procsput(CP1CS, cs);
  940. X
  941. X    return dipc;
  942. X}
  943. X
  944. Xdinstrn    *
  945. Xi_cvtd(dipc, fmt, ft, fs, fd)
  946. Xdinstrn    *dipc;
  947. Xint        fmt;
  948. Xint        ft;
  949. Xint        fs;
  950. Xint        fd;
  951. X{
  952. X    float    singlef;
  953. X    double    doublef;
  954. X    long    fixedf;
  955. X
  956. X    switch (fmt)
  957. X    {
  958. X    case FMT_SINGLE:
  959. X        procsget(CP1G(fs), *(unsigned long *)&singlef);
  960. X
  961. X        doublef = singlef;
  962. X        break;
  963. X
  964. X    case FMT_FIXED:
  965. X        procsget(CP1G(fs), fixedf);
  966. X
  967. X        doublef = fixedf;
  968. X        break;
  969. X
  970. X    default:
  971. X        unrecognised(dipc);
  972. X        break;
  973. X    }
  974. X
  975. X    /*
  976. X     * Note apparent reversal of words within
  977. X     * doubles here -- no idea why.
  978. X     */
  979. X
  980. X    procsput(CP1G(fd), *((unsigned long *)&doublef + 1));
  981. X
  982. X    procsput(CP1G(fd) + 1, *(unsigned long *)&doublef);
  983. X
  984. X    return dipc;
  985. X}
  986. X
  987. Xdinstrn    *
  988. Xi_cvts(dipc, fmt, ft, fs, fd)
  989. Xdinstrn    *dipc;
  990. Xint        fmt;
  991. Xint        ft;
  992. Xint        fs;
  993. Xint        fd;
  994. X{
  995. X    float    singlef;
  996. X    double    doublef;
  997. X    long    fixedf;
  998. X
  999. X    switch (fmt)
  1000. X    {
  1001. X    case FMT_DOUBLE:
  1002. X        /*
  1003. X         * Note apparent reversal of words within
  1004. X         * doubles here -- no idea why.
  1005. X         */
  1006. X        procsget(CP1G(fs), *((unsigned long *)&doublef + 1));
  1007. X
  1008. X        procsget(CP1G(fs) + 1, *(unsigned long *)&doublef);
  1009. X
  1010. X        singlef = doublef;
  1011. X        break;
  1012. X
  1013. X    case FMT_FIXED:
  1014. X        procsget(CP1G(fs), fixedf);
  1015. X
  1016. X        singlef = fixedf;
  1017. X        break;
  1018. X
  1019. X    default:
  1020. X        unrecognised(dipc);
  1021. X        break;
  1022. X    }
  1023. X
  1024. X    procsput(CP1G(fd), *(unsigned long *)&singlef);
  1025. X
  1026. X    return dipc;
  1027. X}
  1028. X
  1029. Xdinstrn    *
  1030. Xi_cvtw(dipc, fmt, ft, fs, fd)
  1031. Xdinstrn    *dipc;
  1032. Xint        fmt;
  1033. Xint        ft;
  1034. Xint        fs;
  1035. Xint        fd;
  1036. X{
  1037. X    float    singlef;
  1038. X    double    doublef;
  1039. X    long    fixedf;
  1040. X
  1041. X    switch (fmt)
  1042. X    {
  1043. X    case FMT_SINGLE:
  1044. X        procsget(CP1G(fs), *(unsigned long *)&singlef);
  1045. X
  1046. X        fixedf = singlef;
  1047. X        break;
  1048. X
  1049. X    case FMT_DOUBLE:
  1050. X        /*
  1051. X         * Note apparent reversal of words within
  1052. X         * doubles here -- no idea why.
  1053. X         */
  1054. X        procsget(CP1G(fs), *((unsigned long *)&doublef + 1));
  1055. X
  1056. X        procsget(CP1G(fs) + 1, *(unsigned long *)&doublef);
  1057. X
  1058. X        fixedf = doublef;
  1059. X        break;
  1060. X
  1061. X    default:
  1062. X        unrecognised(dipc);
  1063. X        break;
  1064. X    }
  1065. X
  1066. X    procsput(CP1G(fd), fixedf);
  1067. X
  1068. X    return dipc;
  1069. X}
  1070. END_OF_FILE
  1071. if test 8817 -ne `wc -c <'i_c.c'`; then
  1072.     echo shar: \"'i_c.c'\" unpacked with wrong size!
  1073. fi
  1074. # end of 'i_c.c'
  1075. fi
  1076. if test -f 'i_s.c' -a "${1}" != "-c" ; then 
  1077.   echo shar: Will not clobber existing file \"'i_s.c'\"
  1078. else
  1079. echo shar: Extracting \"'i_s.c'\" \(11592 characters\)
  1080. sed "s/^X//" >'i_s.c' <<'END_OF_FILE'
  1081. X#include    "register.h"
  1082. X#include    "symtab.h"
  1083. X#include    "diblock.h"
  1084. X#include    "instrn.h"
  1085. X#include    "process.h"
  1086. X#include    "wcache.h"
  1087. X
  1088. X/*
  1089. X * TODO -- big-endian v. little-endian.
  1090. X */
  1091. X
  1092. X#define    quiet_procmput_word(dipc,offset,w,n,S) \
  1093. X{ \
  1094. X    int        i; \
  1095. X    unsigned long    *wp; \
  1096. X \
  1097. X    if ((i = offset - P.p_data_region_min) >= 0) \
  1098. X    { \
  1099. X        if (n == sizeof(int)) \
  1100. X        { \
  1101. X            if (offset <= P.p_data_region_wlimit) \
  1102. X            { \
  1103. X                wp = (unsigned long *)&P.p_data_region[i]; \
  1104. X                *wp = w; \
  1105. X                S; \
  1106. X                return dipc; \
  1107. X            } \
  1108. X        } \
  1109. X        else if (n == sizeof(short)) \
  1110. X        { \
  1111. X            if (offset <= P.p_data_region_limit + 1 - n) \
  1112. X            { \
  1113. X                *(unsigned short *)&P.p_data_region[i] = w; \
  1114. X                return dipc; \
  1115. X            } \
  1116. X        } \
  1117. X        else \
  1118. X        { \
  1119. X            if (offset <= P.p_data_region_limit) \
  1120. X            { \
  1121. X                *(unsigned char *)&P.p_data_region[i] = w; \
  1122. X                return dipc; \
  1123. X            } \
  1124. X        } \
  1125. X \
  1126. X        if (offset <= STACK_WMAX) \
  1127. X        { \
  1128. X            if ((i = offset - P.p_stack_region_min) < 0) \
  1129. X            { \
  1130. X                (void)proc_grow_stack(dipc, offset); \
  1131. X \
  1132. X                i = offset - P.p_stack_region_min; \
  1133. X            } \
  1134. X \
  1135. X            if (n == sizeof(int)) \
  1136. X            { \
  1137. X                wp = (unsigned long *)&P.p_stack_region[i]; \
  1138. X                *wp = w; \
  1139. X                S; \
  1140. X            } \
  1141. X            else if (n == sizeof(short)) \
  1142. X                *(unsigned short *)&P.p_stack_region[i] = w; \
  1143. X            else \
  1144. X                *(unsigned char *)&P.p_stack_region[i] = w; \
  1145. X \
  1146. X            return dipc; \
  1147. X        } \
  1148. X    } \
  1149. X \
  1150. X    (void)quiet_procmput(dipc, offset, (unsigned char *)&w, n); \
  1151. X    return dipc; \
  1152. X}
  1153. X
  1154. Xstatic
  1155. Xdinstrn    *
  1156. Xc_sb(dipc)
  1157. Xdinstrn    *dipc;
  1158. X{
  1159. X    unsigned long    addr;
  1160. X    unsigned char    c;
  1161. X
  1162. X    addr = *dipc->di_1 + (long)dipc->di_2;
  1163. X    c = *dipc->di_0;
  1164. X
  1165. X    quiet_procmput_word(dipc, addr, c, sizeof(c), ;);
  1166. X}
  1167. X
  1168. Xdinstrn    *
  1169. Xi_sb(dipc, base, rt, offset)
  1170. Xdinstrn    *dipc;
  1171. Xint    base;
  1172. Xint    rt;
  1173. Xshort    offset;
  1174. X{
  1175. X    unsigned long    b;
  1176. X    unsigned long    t;
  1177. X    unsigned char    c;
  1178. X
  1179. X    if (compile_ok)
  1180. X    {
  1181. X        dipc->di_handler = c_sb;
  1182. X        dipc->di_0 = &P.p_state[rt];
  1183. X        dipc->di_1 = &P.p_state[base];
  1184. X        dipc->di_2 = (unsigned long *)(long)offset;
  1185. X
  1186. X        return (*dipc->di_handler)(dipc);
  1187. X    }
  1188. X
  1189. X    procsget(base, b);
  1190. X
  1191. X    procsget(rt, t);
  1192. X
  1193. X    c = t;
  1194. X
  1195. X    (void)procmput(dipc, b + (long)offset, (char *)&c, sizeof(c));
  1196. X
  1197. X    return dipc;
  1198. X}
  1199. X
  1200. Xstatic
  1201. Xdinstrn    *
  1202. Xc_sh(dipc)
  1203. Xdinstrn    *dipc;
  1204. X{
  1205. X    unsigned long    addr;
  1206. X    unsigned short    h;
  1207. X
  1208. X    addr = *dipc->di_1 + (long)dipc->di_2;
  1209. X    h = *dipc->di_0;
  1210. X
  1211. X    check_halfword_align(dipc, addr);
  1212. X
  1213. X    quiet_procmput_word(dipc, addr, h, sizeof(h), ;);
  1214. X}
  1215. X
  1216. Xdinstrn    *
  1217. Xi_sh(dipc, base, rt, offset)
  1218. Xdinstrn    *dipc;
  1219. Xint    base;
  1220. Xint    rt;
  1221. Xshort    offset;
  1222. X{
  1223. X    unsigned long    b;
  1224. X    unsigned long    addr;
  1225. X    unsigned long    t;
  1226. X    unsigned short    h;
  1227. X
  1228. X    if (compile_ok)
  1229. X    {
  1230. X        dipc->di_handler = c_sh;
  1231. X        dipc->di_0 = &P.p_state[rt];
  1232. X        dipc->di_1 = &P.p_state[base];
  1233. X        dipc->di_2 = (unsigned long *)(long)offset;
  1234. X
  1235. X        return (*dipc->di_handler)(dipc);
  1236. X    }
  1237. X
  1238. X    procsget(base, b);
  1239. X
  1240. X    addr = b + offset;
  1241. X
  1242. X    check_halfword_align(dipc, addr);
  1243. X
  1244. X    procsget(rt, t);
  1245. X
  1246. X    h = t;
  1247. X
  1248. X    (void)procmput(dipc, addr, (char *)&h, sizeof(h));
  1249. X
  1250. X    return dipc;
  1251. X}
  1252. X
  1253. Xstatic
  1254. Xdinstrn    *
  1255. Xc_sll(dipc)
  1256. Xdinstrn    *dipc;
  1257. X{
  1258. X    *dipc->di_0 = *dipc->di_1 << (int)dipc->di_2;
  1259. X
  1260. X    return dipc;
  1261. X}
  1262. X
  1263. Xdinstrn    *
  1264. Xi_sll(dipc, rs, rt, rd, shamt, funct)
  1265. Xdinstrn    *dipc;
  1266. Xint    rs;
  1267. Xint    rt;
  1268. Xint    rd;
  1269. Xint    shamt;
  1270. Xint    funct;
  1271. X{
  1272. X    unsigned long    t;
  1273. X
  1274. X    if (compile_ok)
  1275. X    {
  1276. X        if (rd == R_0)
  1277. X            dipc->di_handler = c_noop;
  1278. X        else
  1279. X        {
  1280. X            dipc->di_handler = c_sll;
  1281. X            dipc->di_0 = &P.p_state[rd];
  1282. X            dipc->di_1 = &P.p_state[rt];
  1283. X            dipc->di_2 = (unsigned long *)shamt;
  1284. X        }
  1285. X
  1286. X        return (*dipc->di_handler)(dipc);
  1287. X    }
  1288. X
  1289. X    procsget(rt, t);
  1290. X
  1291. X    procsput(rd, t << shamt);
  1292. X
  1293. X    return dipc;
  1294. X}
  1295. X
  1296. Xdinstrn    *
  1297. Xi_sllv(dipc, rs, rt, rd, shamt, funct)
  1298. Xdinstrn    *dipc;
  1299. Xint    rs;
  1300. Xint    rt;
  1301. Xint    rd;
  1302. Xint    shamt;
  1303. Xint    funct;
  1304. X{
  1305. X    unsigned long    t;
  1306. X    unsigned long    s;
  1307. X
  1308. X    procsget(rt, t);
  1309. X
  1310. X    procsget(rs, s);
  1311. X
  1312. X    procsput(rd, t << (s & 0x1F));
  1313. X
  1314. X    return dipc;
  1315. X}
  1316. X
  1317. Xstatic
  1318. Xdinstrn    *
  1319. Xc_slt(dipc)
  1320. Xdinstrn    *dipc;
  1321. X{
  1322. X    *dipc->di_0 = ((long)*dipc->di_1 < (long)*dipc->di_2) ? 1 : 0;
  1323. X
  1324. X    return dipc;
  1325. X}
  1326. X
  1327. Xdinstrn    *
  1328. Xi_slt(dipc, rs, rt, rd, shamt, funct)
  1329. Xdinstrn    *dipc;
  1330. Xint    rs;
  1331. Xint    rt;
  1332. Xint    rd;
  1333. Xint    shamt;
  1334. Xint    funct;
  1335. X{
  1336. X    long    s;
  1337. X    long    t;
  1338. X
  1339. X    if (compile_ok)
  1340. X    {
  1341. X        if (rd == R_0)
  1342. X            dipc->di_handler = c_noop;
  1343. X        else
  1344. X        {
  1345. X            dipc->di_handler = c_slt;
  1346. X            dipc->di_0 = &P.p_state[rd];
  1347. X            dipc->di_1 = &P.p_state[rs];
  1348. X            dipc->di_2 = &P.p_state[rt];
  1349. X        }
  1350. X
  1351. X        return (*dipc->di_handler)(dipc);
  1352. X    }
  1353. X
  1354. X    procsget(rs, *(unsigned long *)&s);
  1355. X
  1356. X    procsget(rt, *(unsigned long *)&t);
  1357. X
  1358. X    procsput(rd, (s < t) ? 1 : 0);
  1359. X
  1360. X    return dipc;
  1361. X}
  1362. X
  1363. Xdinstrn    *
  1364. Xi_slti(dipc, rs, rt, immediate)
  1365. Xdinstrn    *dipc;
  1366. Xint    rs;
  1367. Xint    rt;
  1368. Xshort    immediate;
  1369. X{
  1370. X    long    s;
  1371. X
  1372. X    procsget(rs, *(unsigned long *)&s);
  1373. X
  1374. X    procsput(rt, (s < (long)immediate) ? 1 : 0);
  1375. X
  1376. X    return dipc;
  1377. X}
  1378. X
  1379. Xstatic
  1380. Xdinstrn    *
  1381. Xc_sltiu(dipc)
  1382. Xdinstrn    *dipc;
  1383. X{
  1384. X    *dipc->di_0 = (*dipc->di_1 < (unsigned long)dipc->di_2) ? 1 : 0;
  1385. X
  1386. X    return dipc;
  1387. X}
  1388. X
  1389. Xdinstrn    *
  1390. Xi_sltiu(dipc, rs, rt, immediate)
  1391. Xdinstrn    *dipc;
  1392. Xint    rs;
  1393. Xint    rt;
  1394. Xshort    immediate;
  1395. X{
  1396. X    unsigned long    s;
  1397. X    long        i;
  1398. X    unsigned long    ui;
  1399. X
  1400. X    i = immediate;
  1401. X    ui = i;
  1402. X
  1403. X    if (compile_ok)
  1404. X    {
  1405. X        if (rt == R_0)
  1406. X            dipc->di_handler = c_noop;
  1407. X        else
  1408. X        {
  1409. X            dipc->di_handler = c_sltiu;
  1410. X            dipc->di_0 = &P.p_state[rt];
  1411. X            dipc->di_1 = &P.p_state[rs];
  1412. X            dipc->di_2 = (unsigned long *)ui;
  1413. X        }
  1414. X
  1415. X        return (*dipc->di_handler)(dipc);
  1416. X    }
  1417. X
  1418. X    procsget(rs, s);
  1419. X
  1420. X    procsput(rt, (s < ui) ? 1 : 0);
  1421. X
  1422. X    return dipc;
  1423. X}
  1424. X
  1425. Xstatic
  1426. Xdinstrn    *
  1427. Xc_sltu(dipc)
  1428. Xdinstrn    *dipc;
  1429. X{
  1430. X    *dipc->di_0 = (*dipc->di_1 < *dipc->di_2) ? 1 : 0;
  1431. X
  1432. X    return dipc;
  1433. X}
  1434. X
  1435. Xdinstrn    *
  1436. Xi_sltu(dipc, rs, rt, rd, shamt, funct)
  1437. Xdinstrn    *dipc;
  1438. Xint    rs;
  1439. Xint    rt;
  1440. Xint    rd;
  1441. Xint    shamt;
  1442. Xint    funct;
  1443. X{
  1444. X    unsigned long    s;
  1445. X    unsigned long    t;
  1446. X
  1447. X    if (compile_ok)
  1448. X    {
  1449. X        if (rd == R_0)
  1450. X            dipc->di_handler = c_noop;
  1451. X        else
  1452. X        {
  1453. X            dipc->di_handler = c_sltu;
  1454. X            dipc->di_0 = &P.p_state[rd];
  1455. X            dipc->di_1 = &P.p_state[rs];
  1456. X            dipc->di_2 = &P.p_state[rt];
  1457. X        }
  1458. X
  1459. X        return (*dipc->di_handler)(dipc);
  1460. X    }
  1461. X
  1462. X    procsget(rs, s);
  1463. X
  1464. X    procsget(rt, t);
  1465. X
  1466. X    procsput(rd, (s < t) ? 1 : 0);
  1467. X
  1468. X    return dipc;
  1469. X}
  1470. X
  1471. Xstatic
  1472. Xdinstrn    *
  1473. Xc_sra(dipc)
  1474. Xdinstrn    *dipc;
  1475. X{
  1476. X    *dipc->di_0 = (unsigned long)(((long)*dipc->di_2) >> (int)dipc->di_1);
  1477. X
  1478. X    return dipc;
  1479. X}
  1480. X
  1481. Xdinstrn    *
  1482. Xi_sra(dipc, rs, rt, rd, shamt, funct)
  1483. Xdinstrn    *dipc;
  1484. Xint    rs;
  1485. Xint    rt;
  1486. Xint    rd;
  1487. Xint    shamt;
  1488. Xint    funct;
  1489. X{
  1490. X    long    t;
  1491. X
  1492. X    if (compile_ok)
  1493. X    {
  1494. X        if (rd == R_0)
  1495. X            dipc->di_handler = c_noop;
  1496. X        else
  1497. X        {
  1498. X            dipc->di_handler = c_sra;
  1499. X            dipc->di_0 = &P.p_state[rd];
  1500. X            dipc->di_1 = (unsigned long *)shamt;
  1501. X            dipc->di_2 = &P.p_state[rt];
  1502. X        }
  1503. X
  1504. X        return (*dipc->di_handler)(dipc);
  1505. X    }
  1506. X
  1507. X    procsget(rt, *(unsigned long *)&t);
  1508. X
  1509. X    procsput(rd, t >> shamt);
  1510. X
  1511. X    return dipc;
  1512. X}
  1513. X
  1514. Xdinstrn    *
  1515. Xi_srav(dipc, rs, rt, rd, shamt, funct)
  1516. Xdinstrn    *dipc;
  1517. Xint    rs;
  1518. Xint    rt;
  1519. Xint    rd;
  1520. Xint    shamt;
  1521. Xint    funct;
  1522. X{
  1523. X    long        t;
  1524. X    unsigned long    s;
  1525. X
  1526. X    procsget(rt, *(unsigned long *)&t);
  1527. X
  1528. X    procsget(rs, s);
  1529. X
  1530. X    procsput(rd, t >> (s & 0x1F));
  1531. X
  1532. X    return dipc;
  1533. X}
  1534. X
  1535. Xdinstrn    *
  1536. Xi_srl(dipc, rs, rt, rd, shamt, funct)
  1537. Xdinstrn    *dipc;
  1538. Xint    rs;
  1539. Xint    rt;
  1540. Xint    rd;
  1541. Xint    shamt;
  1542. Xint    funct;
  1543. X{
  1544. X    unsigned long    t;
  1545. X
  1546. X    procsget(rt, t);
  1547. X
  1548. X    procsput(rd, t >> shamt);
  1549. X
  1550. X    return dipc;
  1551. X}
  1552. X
  1553. Xdinstrn    *
  1554. Xi_srlv(dipc, rs, rt, rd, shamt, funct)
  1555. Xdinstrn    *dipc;
  1556. Xint    rs;
  1557. Xint    rt;
  1558. Xint    rd;
  1559. Xint    shamt;
  1560. Xint    funct;
  1561. X{
  1562. X    unsigned long    t;
  1563. X    unsigned long    s;
  1564. X
  1565. X    procsget(rt, t);
  1566. X
  1567. X    procsget(rs, s);
  1568. X
  1569. X    procsput(rd, t >> (s & 0x1F));
  1570. X
  1571. X    return dipc;
  1572. X}
  1573. X
  1574. Xdinstrn    *
  1575. Xi_sub(dipc, rs, rt, rd, shamt, funct)
  1576. Xdinstrn    *dipc;
  1577. Xint    rs;
  1578. Xint    rt;
  1579. Xint    rd;
  1580. Xint    shamt;
  1581. Xint    funct;
  1582. X{
  1583. X    unsigned long    s;
  1584. X    unsigned long    t;
  1585. X
  1586. X    procsget(rs, s);
  1587. X
  1588. X    procsget(rt, t);
  1589. X
  1590. X    /*
  1591. X     * TODO -- overflow exception.
  1592. X     */
  1593. X    procsput(rd, s - t);
  1594. X
  1595. X    return dipc;
  1596. X}
  1597. X
  1598. Xdinstrn    *
  1599. Xi_subfmt(dipc, fmt, ft, fs, fd)
  1600. Xdinstrn    *dipc;
  1601. Xint    fmt;
  1602. Xint    ft;
  1603. Xint    fs;
  1604. Xint    fd;
  1605. X{
  1606. X    float        singles;
  1607. X    float        singlet;
  1608. X    float        singled;
  1609. X    double        doubles;
  1610. X    double        doublet;
  1611. X    double        doubled;
  1612. X    unsigned long    l[2];
  1613. X
  1614. X    switch (fmt)
  1615. X    {
  1616. X    case FMT_SINGLE:
  1617. X        procsget(CP1G(fs), *(unsigned long *)&singles);
  1618. X
  1619. X        procsget(CP1G(ft), *(unsigned long *)&singlet);
  1620. X
  1621. X        singled = singles - singlet;
  1622. X
  1623. X        procsput(CP1G(fd), *(unsigned long *)&singled);
  1624. X
  1625. X        break;
  1626. X
  1627. X    case FMT_DOUBLE:
  1628. X        /*
  1629. X         * Note apparent reversal of words within
  1630. X         * doubles here -- no idea why.
  1631. X         */
  1632. X        procsget(CP1G(fs), *((unsigned long *)&doubles + 1));
  1633. X
  1634. X        procsget(CP1G(fs) + 1, *(unsigned long *)&doubles);
  1635. X
  1636. X        procsget(CP1G(ft), *((unsigned long *)&doublet + 1));
  1637. X
  1638. X        procsget(CP1G(ft) + 1, *(unsigned long *)&doublet);
  1639. X
  1640. X        doubled = doubles - doublet;
  1641. X
  1642. X        procsput(CP1G(fd), *((unsigned long *)&doubled + 1));
  1643. X
  1644. X        procsput(CP1G(fd) + 1, *(unsigned long *)&doubled);
  1645. X        break;
  1646. X
  1647. X    default:
  1648. X        unrecognised(dipc);
  1649. X        break;
  1650. X    }
  1651. X
  1652. X    return dipc;
  1653. X}
  1654. X
  1655. Xstatic
  1656. Xdinstrn    *
  1657. Xc_subu(dipc)
  1658. Xdinstrn    *dipc;
  1659. X{
  1660. X    *dipc->di_0 = *dipc->di_1 - *dipc->di_2;
  1661. X
  1662. X    return dipc;
  1663. X}
  1664. X
  1665. Xdinstrn    *
  1666. Xi_subu(dipc, rs, rt, rd, shamt, funct)
  1667. Xdinstrn    *dipc;
  1668. Xint    rs;
  1669. Xint    rt;
  1670. Xint    rd;
  1671. Xint    shamt;
  1672. Xint    funct;
  1673. X{
  1674. X    unsigned long    s;
  1675. X    unsigned long    t;
  1676. X
  1677. X    if (compile_ok)
  1678. X    {
  1679. X        if (rd == R_0)
  1680. X            dipc->di_handler = c_noop;
  1681. X        else
  1682. X        {
  1683. X            dipc->di_handler = c_subu;
  1684. X            dipc->di_0 = &P.p_state[rd];
  1685. X            dipc->di_1 = &P.p_state[rs];
  1686. X            dipc->di_2 = &P.p_state[rt];
  1687. X        }
  1688. X
  1689. X        return (*dipc->di_handler)(dipc);
  1690. X    }
  1691. X
  1692. X    procsget(rs, s);
  1693. X
  1694. X    procsget(rt, t);
  1695. X
  1696. X    procsput(rd, s - t);
  1697. X
  1698. X    return dipc;
  1699. X}
  1700. X
  1701. Xstatic
  1702. Xdinstrn    *
  1703. Xc_sw0(dipc)
  1704. Xdinstrn    *dipc;
  1705. X{
  1706. X    unsigned long    addr;
  1707. X    unsigned long    l;
  1708. X    cent        *cap;
  1709. X
  1710. X    addr = *dipc->di_1;
  1711. X    l = *dipc->di_0;
  1712. X
  1713. X    if ((cap = &wcache[addr % CACHEZ])->c_addr == addr)
  1714. X    {
  1715. X        *cap->c_ptr = l;
  1716. X        return dipc;
  1717. X    }
  1718. X
  1719. X    check_word_align(dipc, addr);
  1720. X
  1721. X    quiet_procmput_word(dipc, addr, l, sizeof(l), cap->c_ptr = wp; cap->c_addr = addr);
  1722. X}
  1723. X
  1724. Xstatic
  1725. Xdinstrn    *
  1726. Xc_sw4(dipc)
  1727. Xdinstrn    *dipc;
  1728. X{
  1729. X    unsigned long    addr;
  1730. X    unsigned long    l;
  1731. X    cent        *cap;
  1732. X
  1733. X    addr = *dipc->di_1 + 4;
  1734. X    l = *dipc->di_0;
  1735. X
  1736. X    if ((cap = &wcache[addr % CACHEZ])->c_addr == addr)
  1737. X    {
  1738. X        *cap->c_ptr = l;
  1739. X        return dipc;
  1740. X    }
  1741. X
  1742. X    check_word_align(dipc, addr);
  1743. X
  1744. X    quiet_procmput_word(dipc, addr, l, sizeof(l), cap->c_ptr = wp; cap->c_addr = addr);
  1745. X}
  1746. X
  1747. Xstatic
  1748. Xdinstrn    *
  1749. Xc_sw(dipc)
  1750. Xdinstrn    *dipc;
  1751. X{
  1752. X    unsigned long    addr;
  1753. X    unsigned long    l;
  1754. X    cent        *cap;
  1755. X
  1756. X    addr = *dipc->di_1 + (long)dipc->di_2;
  1757. X    l = *dipc->di_0;
  1758. X
  1759. X    if ((cap = &wcache[addr % CACHEZ])->c_addr == addr)
  1760. X    {
  1761. X        *cap->c_ptr = l;
  1762. X        return dipc;
  1763. X    }
  1764. X
  1765. X    check_word_align(dipc, addr);
  1766. X
  1767. X    quiet_procmput_word(dipc, addr, l, sizeof(l), cap->c_ptr = wp; cap->c_addr = addr);
  1768. X}
  1769. X
  1770. Xdinstrn    *
  1771. Xi_sw(dipc, base, rt, offset)
  1772. Xdinstrn    *dipc;
  1773. Xint    base;
  1774. Xint    rt;
  1775. Xshort    offset;
  1776. X{
  1777. X    unsigned long    b;
  1778. X    unsigned long    addr;
  1779. X    unsigned long    t;
  1780. X
  1781. X    if (compile_ok)
  1782. X    {
  1783. X        switch (offset)
  1784. X        {
  1785. X        case 0:
  1786. X            dipc->di_handler = c_sw0;
  1787. X            break;
  1788. X
  1789. X        case 4:
  1790. X            dipc->di_handler = c_sw4;
  1791. X            break;
  1792. X
  1793. X        default:
  1794. X            dipc->di_handler = c_sw;
  1795. X            break;
  1796. X        }
  1797. X        dipc->di_0 = &P.p_state[rt];
  1798. X        dipc->di_1 = &P.p_state[base];
  1799. X        dipc->di_2 = (unsigned long *)(long)offset;
  1800. X
  1801. X        return (*dipc->di_handler)(dipc);
  1802. X    }
  1803. X
  1804. X    procsget(base, b);
  1805. X
  1806. X    addr = b + (long)offset;
  1807. X
  1808. X    check_word_align(dipc, addr);
  1809. X
  1810. X    procsget(rt, t);
  1811. X
  1812. X    (void)procmput(dipc, addr, (char *)&t, sizeof(t));
  1813. X
  1814. X    return dipc;
  1815. X}
  1816. X
  1817. Xdinstrn    *
  1818. Xi_swc1(dipc, base, rt, offset)
  1819. Xdinstrn    *dipc;
  1820. Xint    base;
  1821. Xint    rt;
  1822. Xshort    offset;
  1823. X{
  1824. X    unsigned long    b;
  1825. X    unsigned long    addr;
  1826. X    unsigned long    t;
  1827. X
  1828. X    procsget(base, b);
  1829. X
  1830. X    addr = b + (long)offset;
  1831. X
  1832. X    check_word_align(dipc, addr);
  1833. X
  1834. X    procsget(CP1G(rt), t);
  1835. X
  1836. X    (void)procmput(dipc, addr, (char *)&t, sizeof(t));
  1837. X
  1838. X    return dipc;
  1839. X}
  1840. X
  1841. Xdinstrn    *
  1842. Xi_swl(dipc, base, rt, offset)
  1843. Xdinstrn    *dipc;
  1844. Xint    base;
  1845. Xint    rt;
  1846. Xshort    offset;
  1847. X{
  1848. X    unsigned long    b;
  1849. X    unsigned long    addr;
  1850. X    unsigned long    t;
  1851. X    int        length;
  1852. X
  1853. X    procsget(base, b);
  1854. X
  1855. X    addr = b + (long)offset;
  1856. X
  1857. X    procsget(rt, t);
  1858. X
  1859. X    length = sizeof(t) - (addr - (addr & ~0x3));
  1860. X
  1861. X    (void)procmput(dipc, addr, (char *)&t, length);
  1862. X
  1863. X    return dipc;
  1864. X}
  1865. X
  1866. Xdinstrn    *
  1867. Xi_swr(dipc, base, rt, offset)
  1868. Xdinstrn    *dipc;
  1869. Xint    base;
  1870. Xint    rt;
  1871. Xshort    offset;
  1872. X{
  1873. X    unsigned long    b;
  1874. X    unsigned long    addr;
  1875. X    unsigned long    t;
  1876. X    int        length;
  1877. X
  1878. X    procsget(base, b);
  1879. X
  1880. X    addr = b + (long)offset;
  1881. X
  1882. X    procsget(rt, t);
  1883. X
  1884. X    length = (addr - (addr & ~0x3)) + 1;
  1885. X
  1886. X    (void)procmput(dipc, addr & ~0x3, ((char *)&t) + (sizeof(t) - length), length);
  1887. X
  1888. X    return dipc;
  1889. X}
  1890. END_OF_FILE
  1891. if test 11592 -ne `wc -c <'i_s.c'`; then
  1892.     echo shar: \"'i_s.c'\" unpacked with wrong size!
  1893. fi
  1894. # end of 'i_s.c'
  1895. fi
  1896. if test -f 'main.c' -a "${1}" != "-c" ; then 
  1897.   echo shar: Will not clobber existing file \"'main.c'\"
  1898. else
  1899. echo shar: Extracting \"'main.c'\" \(9515 characters\)
  1900. sed "s/^X//" >'main.c' <<'END_OF_FILE'
  1901. X#include    <stdio.h>
  1902. X
  1903. X/*
  1904. X * Simulate the execution of a process
  1905. X * on a MIPS R[CS]3330 under RISC/os 4.52.
  1906. X */
  1907. X
  1908. X#define    DEFAULT_OUTNAME    "<stderr>"
  1909. X#define    DEFAULT_OUTFP    stderr
  1910. X
  1911. X#define    toggle(f)    (f) = 1 - (f)
  1912. X
  1913. Xextern int        fd_init();
  1914. Xextern int        hist_init();
  1915. Xextern void        histo_dump();
  1916. Xextern void        hist_dump();
  1917. Xextern char        *strdup();
  1918. Xextern int        getopt();
  1919. Xextern void        usage();
  1920. Xextern int        load();
  1921. Xextern int        go();
  1922. Xextern char        *execvpath();
  1923. Xextern int        setobuf();
  1924. X
  1925. Xextern int        optind;
  1926. Xextern char        *optarg;
  1927. X
  1928. Xchar            **gargv;
  1929. Xchar            **genvp;
  1930. Xchar            *usage_args    = " [-ABCFHILMNPRSTVW] [-a argc] [-d fd] [-f executable ] [-h history_length] [-o outfile] [-v] [command ..]";
  1931. Xchar            *getopt_args    =    "ABCFHILMNPRSTVWa:d:f:h:o:v";
  1932. Xint            Aflag;        /* show read/write/execve args    */
  1933. Xint            Bflag;        /* print page no.s        */
  1934. Xint            Cflag;        /* C-like trace format        */
  1935. Xint            Fflag;        /* follow across execvp        */
  1936. Xint            Hflag;        /* emit an execution histogram    */
  1937. Xint            Iflag;        /* show instructions        */
  1938. Xint            Lflag    = 1;    /* line buffer output        */
  1939. Xint            Mflag;        /* show memory accesses        */
  1940. Xint            Nflag;        /* show instrn counts        */
  1941. Xint            Pflag;        /* show syscalls before        */
  1942. Xint            Rflag;        /* show register accesses    */
  1943. Xint            Sflag    = 1;    /* show syscalls after        */
  1944. Xint            Tflag;        /* show system time        */
  1945. Xint            Vflag;        /* be verbose            */
  1946. Xint            Wflag    = 1;    /* truncate outfile b4 writing    */
  1947. XFILE            *outfp    = DEFAULT_OUTFP;
  1948. Xchar            *adotout;    /* explicit executable        */
  1949. Xint            nargc    = -1;    /* # of argv's before env's    */
  1950. X
  1951. Xunsigned long        instruction_count;
  1952. Xunsigned long        instruction_count_since_last_syscall;
  1953. X
  1954. Xstatic char        *version_string    = "Version 5";
  1955. Xstatic int        output_file_has_been_specified;
  1956. Xstatic char        *default_argv[]    =
  1957. X{
  1958. X    "a.out",
  1959. X    (char *)0
  1960. X};
  1961. X
  1962. Xmain(argc, argv, envp)
  1963. Xint    argc;
  1964. Xchar    *argv[];
  1965. Xchar    *envp[];
  1966. X{
  1967. X    int    c;
  1968. X    char    *newoutfile;
  1969. X    int    newoutfd;
  1970. X    FILE    *newoutfp;
  1971. X    char    **app;
  1972. X    char    **epp;
  1973. X
  1974. X    gargv = &argv[0];
  1975. X    genvp = &envp[0];
  1976. X
  1977. X    newoutfile = (char *)0;
  1978. X    newoutfd = -1;
  1979. X
  1980. X    while ((c = getopt(argc, argv, getopt_args)) != -1)
  1981. X    {
  1982. X        switch (c)
  1983. X        {
  1984. X        case 'A':
  1985. X            toggle(Aflag);
  1986. X            break;
  1987. X
  1988. X        case 'B':
  1989. X            toggle(Bflag);
  1990. X            break;
  1991. X
  1992. X        case 'C':
  1993. X            toggle(Cflag);
  1994. X            break;
  1995. X
  1996. X        case 'F':
  1997. X            toggle(Fflag);
  1998. X            break;
  1999. X
  2000. X        case 'H':
  2001. X            toggle(Hflag);
  2002. X            break;
  2003. X
  2004. X        case 'I':
  2005. X            toggle(Iflag);
  2006. X            break;
  2007. X
  2008. X        case 'L':
  2009. X            toggle(Lflag);
  2010. X            break;
  2011. X
  2012. X        case 'M':
  2013. X            toggle(Mflag);
  2014. X            break;
  2015. X
  2016. X        case 'N':
  2017. X            toggle(Nflag);
  2018. X            break;
  2019. X
  2020. X        case 'P':
  2021. X            toggle(Pflag);
  2022. X            break;
  2023. X
  2024. X        case 'R':
  2025. X            toggle(Rflag);
  2026. X            break;
  2027. X
  2028. X        case 'S':
  2029. X            toggle(Sflag);
  2030. X            break;
  2031. X
  2032. X        case 'T':
  2033. X            toggle(Tflag);
  2034. X            break;
  2035. X
  2036. X        case 'V':
  2037. X            toggle(Vflag);
  2038. X            break;
  2039. X
  2040. X        case 'W':
  2041. X            toggle(Wflag);
  2042. X            break;
  2043. X
  2044. X        case 'a':
  2045. X            nargc = atoi(optarg);
  2046. X            break;
  2047. X
  2048. X        case 'd':
  2049. X            newoutfd = atoi(optarg);
  2050. X            break;
  2051. X
  2052. X        case 'f':
  2053. X            adotout = optarg;
  2054. X            break;
  2055. X
  2056. X        case 'h':
  2057. X            if (hist_init(atoi(optarg)) == -1)
  2058. X                exit(1);
  2059. X            break;
  2060. X
  2061. X        case 'o':
  2062. X            newoutfile = optarg;
  2063. X            output_file_has_been_specified = 1;
  2064. X            break;
  2065. X
  2066. X        case 'v':
  2067. X            printf("%s\n", version_string);
  2068. X            exit(0);
  2069. X            break;
  2070. X
  2071. X        case '?':
  2072. X        default:
  2073. X            usage();
  2074. X            exit(1);
  2075. X        }
  2076. X    }
  2077. X
  2078. X    /*
  2079. X     * Trailing arguments?
  2080. X     */
  2081. X    if (optind >= argc)
  2082. X    {
  2083. X        /*
  2084. X         * No -- use the default.
  2085. X         */
  2086. X        app = &default_argv[0];
  2087. X        epp = &envp[0];
  2088. X    }
  2089. X    else
  2090. X    {
  2091. X        /*
  2092. X         * Yes -- use them.
  2093. X         */
  2094. X        app = &argv[optind];
  2095. X        if (nargc == -1)
  2096. X            epp = &envp[0];
  2097. X        else
  2098. X        {
  2099. X            /*
  2100. X             * Overwrite the dummy argument
  2101. X             * to use it as an argument vector terminator.
  2102. X             * The environment will be got from
  2103. X             * the rest.
  2104. X             */
  2105. X            argv[optind + nargc] = (char *)0;
  2106. X            epp = &argv[optind + nargc + 1];
  2107. X        }
  2108. X    }
  2109. X
  2110. X    if (adotout == (char *)0)
  2111. X    {
  2112. X        /*
  2113. X         * Find the executable.
  2114. X         */
  2115. X        if ((adotout = execvpath(*app)) == (char *)0)
  2116. X        {
  2117. X            couldnot("find executable \"%s\"", *app);
  2118. X            exit(1);
  2119. X        }
  2120. X    }
  2121. X
  2122. X    if (fd_init(newoutfd) == -1)
  2123. X        exit(1);
  2124. X
  2125. X    if (output_file_has_been_specified)
  2126. X    {
  2127. X        if (Wflag)
  2128. X        {
  2129. X            if ((newoutfp = fopen(newoutfile, "w")) == (FILE *)0)
  2130. X            {
  2131. X                couldnot("fopen(\"%s\", \"w\")", newoutfile);
  2132. X                exit(1);
  2133. X            }
  2134. X            (void)fclose(newoutfp);
  2135. X        }
  2136. X
  2137. X        if ((newoutfp = fopen(newoutfile, "a")) == (FILE *)0)
  2138. X        {
  2139. X            couldnot("fopen(\"%s\", \"a\")", newoutfile);
  2140. X            exit(1);
  2141. X        }
  2142. X    }
  2143. X    else
  2144. X    {
  2145. X        if (newoutfd == -1)
  2146. X        {
  2147. X            if ((newoutfd = dup(1)) == -1)
  2148. X            {
  2149. X                couldnot("dup(1)");
  2150. X                exit(1);
  2151. X            }
  2152. X        }
  2153. X
  2154. X        if ((newoutfp = fdopen(newoutfd, "a")) == (FILE *)0)
  2155. X        {
  2156. X            couldnot("fdopen(%d, \"a\")", newoutfd);
  2157. X            exit(1);
  2158. X        }
  2159. X    }
  2160. X
  2161. X    outfp = newoutfp;
  2162. X
  2163. X    if (setobuf() == -1)
  2164. X        exit(1);
  2165. X
  2166. X    if (load(adotout, app, epp) == -1)
  2167. X        exit(1);
  2168. X
  2169. X    if (go() == -1)
  2170. X    {
  2171. X        histo_dump();
  2172. X        hist_dump();
  2173. X        exit(1);
  2174. X    }
  2175. X
  2176. X    histo_dump();
  2177. X    hist_dump();
  2178. X
  2179. X    exit(0);
  2180. X}
  2181. X
  2182. Xint
  2183. Xsetobuf()
  2184. X{
  2185. X    if (Lflag)
  2186. X    {
  2187. X        static char    obuf[4096];
  2188. X
  2189. X        if (setvbuf(outfp, &obuf[0], _IOLBF, sizeof(obuf)) != 0)
  2190. X        {
  2191. X            couldnot("set line buffering on output file");
  2192. X            return -1;
  2193. X        }
  2194. X    }
  2195. X
  2196. X    return 0;
  2197. X}
  2198. X
  2199. Xstatic
  2200. Xchar    *
  2201. Xitoa(i)
  2202. Xint    i;
  2203. X{
  2204. X    static char    result[16];
  2205. X
  2206. X    (void)sprintf(&result[0], "%d", i);
  2207. X
  2208. X    return &result[0];
  2209. X}
  2210. X
  2211. X#define    duplicate(f,cp,l)    { if (f) *cp++ = l; }
  2212. X#define    negate(f,cp,l)        duplicate(!(f), (cp), (l))
  2213. X
  2214. X/*
  2215. X * We are given a (filename,argument,environment) vector that
  2216. X * looks like this:
  2217. X *
  2218. X *    filename,
  2219. X *    arg[0], arg[1], ..., arg[N-1]
  2220. X *    env[0], env[1], ..., env[M-1]
  2221. X *
  2222. X * while our arguments are gargv[0], ..., gargv[A-1].
  2223. X * and our environment is genv[0], ..., genv[G-1].
  2224. X *
  2225. X * We make the (filename,argument,environment) vector look
  2226. X * like this:
  2227. X *
  2228. X *    execvpath(gargv[0])
  2229. X *    execvpath(gargv[0]), -d, fd, -myflags, -f, filename, -a, N, --, argv[0], argv[1], ..., argv[N-1], E, env[0], env[1], ..., env[E-1]
  2230. X *    genv[0], genv[1], ..., genv[G-1]
  2231. X *
  2232. X * and we leave our environment as is.
  2233. X *
  2234. X * e.g.
  2235. X *
  2236. X *    /bin/sh
  2237. X *    -sh
  2238. X *    PATH=...
  2239. X *
  2240. X * might become
  2241. X *
  2242. X *    /usr/local/bin/trash
  2243. X *    /usr/local/bin/trash -d 18 -ABFT -f /bin/sh -a 1 -- -sh 23 PATH=...
  2244. X *    HOME=...
  2245. X */
  2246. Xint
  2247. Xaugment_execve_args(fp, appp, eppp)
  2248. Xchar    **fp;
  2249. Xchar    ***appp;
  2250. Xchar    ***eppp;
  2251. X{
  2252. X    char    flagsbuf[128];
  2253. X    int    argc;
  2254. X    char    **argp;
  2255. X    int    envc;
  2256. X    char    **envp;
  2257. X    int    newargc;
  2258. X    char    *result_filename;
  2259. X    char    **result_argp;
  2260. X    char    **result_envp;
  2261. X    int    argi;
  2262. X    int    i;
  2263. X    char    *cp;
  2264. X
  2265. X    /*
  2266. X     * The new filename.
  2267. X     */
  2268. X    if ((result_filename = strdup(execvpath(gargv[0]))) == (char *)0)
  2269. X    {
  2270. X        vcouldnot("allocate enough memory for pre-execve filename");
  2271. X        return -1;
  2272. X    }
  2273. X
  2274. X    /*
  2275. X     * The new arg vector.
  2276. X     */
  2277. X    for (argp = *appp, argc = 0; argp[argc] != (char *)0; argc++)
  2278. X        ;
  2279. X
  2280. X    for (envp = *eppp, envc = 0; envp[envc] != (char *)0; envc++)
  2281. X        ;
  2282. X
  2283. X    newargc = 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + argc + 1 + envc + 1;
  2284. X
  2285. X    if ((result_argp = (char **)malloc(newargc * sizeof(char *))) == (char **)0)
  2286. X    {
  2287. X        vcouldnot("allocate enough memory for %d pre-execve arguments", newargc);
  2288. X        return -1;
  2289. X    }
  2290. X
  2291. X    argi = 0;
  2292. X    if ((result_argp[argi++] = strdup(result_filename)) == (char *)0)
  2293. X    {
  2294. X        vcouldnot("allocate enough memory for pre-execve argv[0]");
  2295. X        return -1;
  2296. X    }
  2297. X
  2298. X{
  2299. X    if ((result_argp[argi++] = strdup("-d")) == (char *)0)
  2300. X    {
  2301. X        vcouldnot("allocate enough memory for pre-execve -d");
  2302. X        return -1;
  2303. X    }
  2304. X    if ((result_argp[argi++] = strdup(itoa(fileno(outfp)))) == (char *)0)
  2305. X    {
  2306. X        vcouldnot("allocate enough memory for pre-execve fd");
  2307. X        return -1;
  2308. X    }
  2309. X}
  2310. X
  2311. X    /*
  2312. X     * Calculate the new flags.
  2313. X     */
  2314. X    cp = &flagsbuf[0];
  2315. X    *cp++ = '-';
  2316. X
  2317. X    duplicate(Aflag, cp, 'A');
  2318. X    duplicate(Bflag, cp, 'B');
  2319. X    duplicate(Cflag, cp, 'C');
  2320. X    duplicate(Fflag, cp, 'F');
  2321. X    duplicate(Iflag, cp, 'I');
  2322. X    negate(Lflag, cp, 'L');
  2323. X    duplicate(Mflag, cp, 'M');
  2324. X    duplicate(Nflag, cp, 'N');
  2325. X    duplicate(Pflag, cp, 'P');
  2326. X    duplicate(Rflag, cp, 'R');
  2327. X    negate(Sflag, cp, 'S');
  2328. X    duplicate(Tflag, cp, 'T');
  2329. X    duplicate(Vflag, cp, 'V');
  2330. X
  2331. X    *cp++ = 'W';
  2332. X    *cp = '\0';
  2333. X
  2334. X    if ((result_argp[argi++] = strdup(&flagsbuf[0])) == (char *)0)
  2335. X    {
  2336. X        vcouldnot("allocate enough memory for pre-execve flagsbuf");
  2337. X        return -1;
  2338. X    }
  2339. X
  2340. X    if ((result_argp[argi++] = strdup("-f")) == (char *)0)
  2341. X    {
  2342. X        vcouldnot("allocate enough memory for pre-execve -f");
  2343. X        return -1;
  2344. X    }
  2345. X    result_argp[argi++] = *fp;
  2346. X
  2347. X    if ((result_argp[argi++] = strdup("-a")) == (char *)0)
  2348. X    {
  2349. X        vcouldnot("allocate enough memory for pre-execve -a");
  2350. X        return -1;
  2351. X    }
  2352. X    if ((result_argp[argi++] = strdup(itoa(argc))) == (char *)0)
  2353. X    {
  2354. X        vcouldnot("allocate enough memory for pre-execve argc");
  2355. X        return -1;
  2356. X    }
  2357. X    if ((result_argp[argi++] = strdup("--")) == (char *)0)
  2358. X    {
  2359. X        vcouldnot("allocate enough memory for pre-execve --");
  2360. X        return -1;
  2361. X    }
  2362. X    for (i = 0; i < argc; i++)
  2363. X        result_argp[argi++] = argp[i];
  2364. X    if ((result_argp[argi++] = strdup(itoa(envc))) == (char *)0)
  2365. X    {
  2366. X        vcouldnot("allocate enough memory for pre-execve envc");
  2367. X        return -1;
  2368. X    }
  2369. X    for (i = 0; i < envc; i++)
  2370. X        result_argp[argi++] = envp[i];
  2371. X    result_argp[argi] = (char *)0;
  2372. X
  2373. X    /*
  2374. X     * The new env vector.
  2375. X     */
  2376. X    for (envc = 0; genvp[envc] != (char *)0; envc++)
  2377. X        ;
  2378. X
  2379. X    if ((result_envp = (char **)malloc((envc + 1) * sizeof(char *))) == (char **)0)
  2380. X    {
  2381. X        vcouldnot("allocate enough memory for %d pre-execve environment strings", envc + 1);
  2382. X        return -1;
  2383. X    }
  2384. X
  2385. X    for (i = 0; i < envc; i++)
  2386. X    {
  2387. X        if ((result_envp[i] = strdup(genvp[i])) == (char *)0)
  2388. X        {
  2389. X            vcouldnot("allocate enough memory for pre-execve env string");
  2390. X            return -1;
  2391. X        }
  2392. X    }
  2393. X    result_envp[i] = (char *)0;
  2394. X
  2395. X    /*
  2396. X     * Assign the results.
  2397. X     */
  2398. X    *fp = result_filename;
  2399. X    *appp = result_argp;
  2400. X    *eppp = result_envp;
  2401. X
  2402. X    /*
  2403. X     * Free up the left-overs.
  2404. X     */
  2405. X    (void)free(argp);
  2406. X    (void)free(envp);
  2407. X
  2408. X    if (Vflag)
  2409. X    {
  2410. X        char    **cp;
  2411. X
  2412. X        fprintf(outfp, "execve'(filename=\"%s\",argv={", *fp);
  2413. X        for (cp = *appp; *cp != (char *)0; cp++)
  2414. X            fprintf(outfp, "\"%s\",", *cp);
  2415. X        fprintf(outfp, "},envp={");
  2416. X        for (cp = *eppp; *cp != (char *)0; cp++)
  2417. X            fprintf(outfp, "\"%s\",", *cp);
  2418. X        fprintf(outfp, "}\n");
  2419. X    }
  2420. X
  2421. X    return 0;
  2422. X}
  2423. END_OF_FILE
  2424. if test 9515 -ne `wc -c <'main.c'`; then
  2425.     echo shar: \"'main.c'\" unpacked with wrong size!
  2426. fi
  2427. # end of 'main.c'
  2428. fi
  2429. echo shar: End of archive 3 \(of 8\).
  2430. cp /dev/null ark3isdone
  2431. MISSING=""
  2432. for I in 1 2 3 4 5 6 7 8 ; do
  2433.     if test ! -f ark${I}isdone ; then
  2434.     MISSING="${MISSING} ${I}"
  2435.     fi
  2436. done
  2437. if test "${MISSING}" = "" ; then
  2438.     echo You have unpacked all 8 archives.
  2439.     rm -f ark[1-9]isdone
  2440. else
  2441.     echo You still need to unpack the following archives:
  2442.     echo "        " ${MISSING}
  2443. fi
  2444. ##  End of shell archive.
  2445. exit 0
  2446.